
$(document).ready(function() { 


        $('.delete_post').live('click',function(){

                var conf = confirm("Are you sure?")
                if (!conf){
                    return false;
                }

                window.location.href = jQuery(this).attr('href');

                return false;

        });



        //log(post_action);

        if(typeof post_action=='undefined')
            {
            //console.log('do nothing')
        }
        else
            {
            //check dropdown methot - valdation
            jQuery.validator.addMethod("check_item_dropdown", function(value, element) {  
                    return this.optional(element) || value != 0  ;   
                }, "Please select an item from the dropdown list.");

            // Override default error message
            jQuery.validator.messages.required = "";

            //FORM VALIDATION
            jQuery(formToSubmit).validate({
                    rules: {
                        /*newObjectDialog_object_type: { check_item_dropdown: true },
                        name: 'required' */
                    }, 
                    highlight: function(element) {
                        $(element).parent().parent().addClass("error");
                    },
                    unhighlight: function(element) {
                        $(element).parent().parent().removeClass("error");
                    },
                    submitHandler: function(form) {

                        //disable add button                            
                        $(formbutton).attr("disabled","disabled");

                        $(formToSubmit+' .status_info').html(loader_html());
                        
                        tinymce.triggerSave();

                        var form = $(formToSubmit);
                        var form_data = form.serialize();

                        $.ajax({
                                url: form.attr('action'),
                                dataType: 'json',
                                type: "POST",
                                data: form_data,
                                success: submit_success,
                                error: function (xhr, textStatus, errorThrown) {
                                    //enable add button                            
                                    $(formbutton).removeAttr("disabled");
                                    $(formToSubmit+' .status_info').html(alert_html('Error ocured...\n'+xhr+'\n'+textStatus+errorThrown+'\n','error'));
                                }
                        });
                    },
                    errorPlacement: function(error, element){}
            })
        }


        $('.jezikIkona').live('click',function(){
                if($(this).parent().parent().hasClass('expanded'))
                    {
                    $(this).parent().parent().removeClass('expanded');
                }else
                    {
                    $(this).parent().parent().addClass('expanded');
                }

        })


});